home *** CD-ROM | disk | FTP | other *** search
- package Box2D.Dynamics
- {
- import Box2D.Collision._cc280;
- import Box2D.Collision._kn203;
- import Box2D.Common.Math._oh327;
- import Box2D.Common.Math._ui293;
- import Box2D.Common.Math.b2Vec2;
- import Box2D.Common._kc225;
- import Box2D.Dynamics.Contacts._dm217;
- import Box2D.Dynamics.Contacts._kg776;
- import Box2D.Dynamics.Contacts._lj358;
- import Box2D.Dynamics.Contacts._nb823;
- import Box2D.Dynamics.Contacts._wf486;
- import Box2D.Dynamics.Joints._yw701;
-
- public class _tn475
- {
- private static var s_reportCR:_wf486 = new _wf486();
-
- public var m_listener:_nu737;
-
- public var m_positionIterationCount:int;
-
- public var m_bodyCapacity:int;
-
- public var m_bodies:Array;
-
- public var m_bodyCount:int;
-
- public var m_contactCapacity:int;
-
- public var m_jointCapacity:int;
-
- public var m_contactCount:int;
-
- public var m_contacts:Array;
-
- public var m_jointCount:int;
-
- public var m_allocator:*;
-
- public var m_joints:Array;
-
- public function _tn475(param1:int, param2:int, param3:int, param4:*, param5:_nu737)
- {
- var _loc6_:int = 0;
- super();
- m_bodyCapacity = param1;
- m_contactCapacity = param2;
- m_jointCapacity = param3;
- m_bodyCount = 0;
- m_contactCount = 0;
- m_jointCount = 0;
- m_allocator = param4;
- m_listener = param5;
- m_bodies = new Array(param1);
- _loc6_ = 0;
- while(_loc6_ < param1)
- {
- m_bodies[_loc6_] = null;
- _loc6_++;
- }
- m_contacts = new Array(param2);
- _loc6_ = 0;
- while(_loc6_ < param2)
- {
- m_contacts[_loc6_] = null;
- _loc6_++;
- }
- m_joints = new Array(param3);
- _loc6_ = 0;
- while(_loc6_ < param3)
- {
- m_joints[_loc6_] = null;
- _loc6_++;
- }
- m_positionIterationCount = 0;
- }
-
- public function _eq278(param1:_ut97, param2:b2Vec2, param3:Boolean, param4:Boolean) : void
- {
- var _loc5_:int = 0;
- var _loc6_:_th791 = null;
- var _loc7_:_yw701 = null;
- var _loc8_:_kg776 = null;
- var _loc9_:int = 0;
- var _loc10_:Boolean = false;
- var _loc11_:Boolean = false;
- var _loc12_:Boolean = false;
- var _loc13_:Number = NaN;
- var _loc14_:Number = NaN;
- var _loc15_:Number = NaN;
- _loc5_ = 0;
- while(_loc5_ < m_bodyCount)
- {
- _loc6_ = m_bodies[_loc5_];
- if(!_loc6_._ur192())
- {
- _loc6_.m_linearVelocity.x += param1.dt * (param2.x + _loc6_.m_invMass * _loc6_.m_force.x);
- _loc6_.m_linearVelocity.y += param1.dt * (param2.y + _loc6_.m_invMass * _loc6_.m_force.y);
- _loc6_.m_angularVelocity += param1.dt * _loc6_.m_invI * _loc6_.m_torque;
- _loc6_.m_force._he34();
- _loc6_.m_torque = 0;
- _loc6_.m_linearVelocity._bx376(_ui293._mx500(1 - param1.dt * _loc6_.m_linearDamping,0,1));
- _loc6_.m_angularVelocity *= _ui293._mx500(1 - param1.dt * _loc6_.m_angularDamping,0,1);
- if(_loc6_.m_linearVelocity._rq734() > _kc225.b2_maxLinearVelocitySquared)
- {
- _loc6_.m_linearVelocity._qi627();
- _loc6_.m_linearVelocity.x *= _kc225.b2_maxLinearVelocity;
- _loc6_.m_linearVelocity.y *= _kc225.b2_maxLinearVelocity;
- }
- if(_loc6_.m_angularVelocity * _loc6_.m_angularVelocity > _kc225.b2_maxAngularVelocitySquared)
- {
- if(_loc6_.m_angularVelocity < 0)
- {
- _loc6_.m_angularVelocity = -_kc225.b2_maxAngularVelocity;
- }
- else
- {
- _loc6_.m_angularVelocity = _kc225.b2_maxAngularVelocity;
- }
- }
- }
- _loc5_++;
- }
- _loc8_ = new _kg776(param1,m_contacts,m_contactCount,m_allocator);
- _loc8_._mf779(param1);
- _loc5_ = 0;
- while(_loc5_ < m_jointCount)
- {
- _loc7_ = m_joints[_loc5_];
- _loc7_._mf779(param1);
- _loc5_++;
- }
- _loc5_ = 0;
- while(_loc5_ < param1.maxIterations)
- {
- _loc8_._md397();
- _loc9_ = 0;
- while(_loc9_ < m_jointCount)
- {
- _loc7_ = m_joints[_loc9_];
- _loc7_._md397(param1);
- _loc9_++;
- }
- _loc5_++;
- }
- _loc8_._wm59();
- _loc5_ = 0;
- while(_loc5_ < m_bodyCount)
- {
- _loc6_ = m_bodies[_loc5_];
- if(!_loc6_._ur192())
- {
- _loc6_.m_sweep.c0._kh737(_loc6_.m_sweep.c);
- _loc6_.m_sweep.a0 = _loc6_.m_sweep.a;
- _loc6_.m_sweep.c.x += param1.dt * _loc6_.m_linearVelocity.x;
- _loc6_.m_sweep.c.y += param1.dt * _loc6_.m_linearVelocity.y;
- _loc6_.m_sweep.a += param1.dt * _loc6_.m_angularVelocity;
- _loc6_._tp414();
- }
- _loc5_++;
- }
- if(param3)
- {
- _loc5_ = 0;
- while(_loc5_ < m_jointCount)
- {
- _loc7_ = m_joints[_loc5_];
- _loc7_._mv73();
- _loc5_++;
- }
- m_positionIterationCount = 0;
- while(m_positionIterationCount < param1.maxIterations)
- {
- _loc10_ = _loc8_._sl623(_kc225.b2_contactBaumgarte);
- _loc11_ = true;
- _loc5_ = 0;
- while(_loc5_ < m_jointCount)
- {
- _loc7_ = m_joints[_loc5_];
- _loc12_ = _loc7_._sl623();
- _loc11_ &&= _loc12_;
- _loc5_++;
- }
- if(_loc10_ && _loc11_)
- {
- break;
- }
- ++m_positionIterationCount;
- }
- }
- _be288(_loc8_.m_constraints);
- if(param4)
- {
- _loc13_ = Number.MAX_VALUE;
- _loc14_ = _kc225.b2_linearSleepTolerance * _kc225.b2_linearSleepTolerance;
- _loc15_ = _kc225.b2_angularSleepTolerance * _kc225.b2_angularSleepTolerance;
- _loc5_ = 0;
- while(_loc5_ < m_bodyCount)
- {
- _loc6_ = m_bodies[_loc5_];
- if(_loc6_.m_invMass != 0)
- {
- if((_loc6_.m_flags & _th791.e_allowSleepFlag) == 0)
- {
- _loc6_.m_sleepTime = 0;
- _loc13_ = 0;
- }
- if((_loc6_.m_flags & _th791.e_allowSleepFlag) == 0 || _loc6_.m_angularVelocity * _loc6_.m_angularVelocity > _loc15_ || _ui293._qr29(_loc6_.m_linearVelocity,_loc6_.m_linearVelocity) > _loc14_)
- {
- _loc6_.m_sleepTime = 0;
- _loc13_ = 0;
- }
- else
- {
- _loc6_.m_sleepTime += param1.dt;
- _loc13_ = _ui293._ct557(_loc13_,_loc6_.m_sleepTime);
- }
- }
- _loc5_++;
- }
- if(_loc13_ >= _kc225.b2_timeToSleep)
- {
- _loc5_ = 0;
- while(_loc5_ < m_bodyCount)
- {
- _loc6_ = m_bodies[_loc5_];
- _loc6_.m_flags |= _th791.e_sleepFlag;
- _loc6_.m_linearVelocity._he34();
- _loc6_.m_angularVelocity = 0;
- _loc5_++;
- }
- }
- }
- }
-
- public function _pa292(param1:_th791) : void
- {
- var _loc2_:* = m_bodyCount++;
- m_bodies[_loc2_] = param1;
- }
-
- public function _be288(param1:Array) : void
- {
- var _loc2_:_oh327 = null;
- var _loc3_:b2Vec2 = null;
- var _loc4_:int = 0;
- var _loc5_:_nb823 = null;
- var _loc6_:_dm217 = null;
- var _loc7_:_wf486 = null;
- var _loc8_:_th791 = null;
- var _loc9_:int = 0;
- var _loc10_:Array = null;
- var _loc11_:int = 0;
- var _loc12_:_kn203 = null;
- var _loc13_:int = 0;
- var _loc14_:_cc280 = null;
- var _loc15_:_lj358 = null;
- if(m_listener == null)
- {
- return;
- }
- _loc4_ = 0;
- while(_loc4_ < m_contactCount)
- {
- _loc5_ = m_contacts[_loc4_];
- _loc6_ = param1[_loc4_];
- _loc7_ = s_reportCR;
- _loc7_.shape1 = _loc5_.m_shape1;
- _loc7_.shape2 = _loc5_.m_shape2;
- _loc8_ = _loc7_.shape1.m_body;
- _loc9_ = _loc5_.m_manifoldCount;
- _loc10_ = _loc5_._sg202();
- _loc11_ = 0;
- while(_loc11_ < _loc9_)
- {
- _loc12_ = _loc10_[_loc11_];
- _loc7_.normal._kh737(_loc12_.normal);
- _loc13_ = 0;
- while(_loc13_ < _loc12_.pointCount)
- {
- _loc14_ = _loc12_.points[_loc13_];
- _loc15_ = _loc6_.points[_loc13_];
- _loc7_.position = _loc8_._pj447(_loc14_.localPoint1);
- _loc7_.normalImpulse = _loc15_.normalImpulse;
- _loc7_.tangentImpulse = _loc15_.tangentImpulse;
- _loc7_.id._aw644 = _loc14_.id._aw644;
- m_listener._kx688(_loc7_);
- _loc13_++;
- }
- _loc11_++;
- }
- _loc4_++;
- }
- }
-
- public function _ti526(param1:_yw701) : void
- {
- var _loc2_:* = m_jointCount++;
- m_joints[_loc2_] = param1;
- }
-
- public function _hu475(param1:_nb823) : void
- {
- var _loc2_:* = m_contactCount++;
- m_contacts[_loc2_] = param1;
- }
-
- public function _re527() : void
- {
- m_bodyCount = 0;
- m_contactCount = 0;
- m_jointCount = 0;
- }
-
- public function _ss251(param1:_ut97) : void
- {
- var _loc2_:int = 0;
- var _loc3_:_kg776 = null;
- var _loc4_:Number = NaN;
- var _loc5_:_th791 = null;
- var _loc6_:Boolean = false;
- _loc3_ = new _kg776(param1,m_contacts,m_contactCount,m_allocator);
- _loc2_ = 0;
- while(_loc2_ < param1.maxIterations)
- {
- _loc3_._md397();
- _loc2_++;
- }
- _loc2_ = 0;
- while(_loc2_ < m_bodyCount)
- {
- _loc5_ = m_bodies[_loc2_];
- if(!_loc5_._ur192())
- {
- _loc5_.m_sweep.c0._kh737(_loc5_.m_sweep.c);
- _loc5_.m_sweep.a0 = _loc5_.m_sweep.a;
- _loc5_.m_sweep.c.x += param1.dt * _loc5_.m_linearVelocity.x;
- _loc5_.m_sweep.c.y += param1.dt * _loc5_.m_linearVelocity.y;
- _loc5_.m_sweep.a += param1.dt * _loc5_.m_angularVelocity;
- _loc5_._tp414();
- }
- _loc2_++;
- }
- _loc4_ = 0.75;
- _loc2_ = 0;
- while(_loc2_ < param1.maxIterations)
- {
- _loc6_ = _loc3_._sl623(_loc4_);
- if(_loc6_)
- {
- break;
- }
- _loc2_++;
- }
- _be288(_loc3_.m_constraints);
- }
- }
- }
-
-